Let's move on to some typical use cases. A common way to use Cloud Run is
to deploy one service connected to a database like you see in the example. You can use this to run a REST API,
a website or a web application. You don't even have to connect with
a database if you're serving machine learning predictions, for example. There is no limit on container image size
while memory size is limited to 8GB. You might want to take that into account. If you go one step further, you can
build a more complex public website, an e-commerce site, for example. In this case you enable Cloud CDN
to improve performance. Add Cloud Armor to filter malicious
inbound traffic using content based policies. In the back end you can connect
with a relational database, a Redls store for user sessions and
connect with third party APIs. Not all applications are public though,
businesses use a lot of internal software, for example, to do time registration or
support other internal business processes. In this example,
add Cloud Identity-Aware Proxy, AIP to handle user authentication with
your existing Google workspace accounts. This type of application typically does
not have high availability requirements. However, if you deploy those on Cloud Run,
they'll just keep on running. You don't have to maintain them or
maintain the service they run on. So far I've only listed relatively
straightforward application designs and for a lot of situations
this is more than enough. Cloud Run, does not require
you to run just one service. You can break down your applications
into multiple services. By default, you can deploy up
to 1000 services in a project. You have multiple options to set up
service to service communication. First, you can use direct RPC calls, REST APIs,
gRPC is supported out of the box. Second you can send asynchronous messages
with guaranteed delivery using Pub/Sub. Pub/Sub is well integrated with
Cloud Run using push subscriptions. Pub/Sub forwards and optionally authenticates messages as
HTTP requests to a Cloud Run Service. Event processing is another
example of use case. Cloud Run integrates with a multitude
of Google cloud services. You can run events from Cloud Storage,
BigQuery, Cloud Build, Pub/Sub and many more. This allows you to build
workflows like this example. Where medical scans are uploaded to
Cloud Storage and forwarded to Cloud Run. Medical imaging devices often have
a life cycle of 20 plus years. And the image files they produce
are often in decades old binary formats. In order to convert that image
data to a more modern format, you'll need a pre-compiled system package
which makes Cloud Run a great choice. While web requests are the only way
to trigger a Cloud Run Service, you can also invoke
Cloud Run Services on a schedule. Examples include to generate invoices and
rebuild a search index. On the surface, this might look a bit
confusing because why wouldn't you just run a scheduled job in a container? Well, this is a useful pattern
as usually the lifetime of a container is only guaranteed
while it is handling requests. If you schedule tasks on
a container to run later, the container might be gone already
by the time the task has run. There's one caveat here,
you shouldn't use Cloud Scheduler for tasks that last longer than 30 minutes,
that's when the request times out. That might have been a lot to take in. So let's summarize the example, use cases. The first and most obvious applications
that handle web requests like web applications, public APIs or websites. You can use additional services on Google
Cloud like CDN and Cloud Armor to make your application performance and
protect against malicious requests. Another sweet spot is internal
line of business items. Cloud Run integrates with identity
aware proxy, IAP so you can use your existing directory of users and
don't need to worry about authentication. Cloud Run is not just for
simple applications. You can run micro service based
applications that communicate using direct RPC or
asynchronous messages over cloud Pub/Sub. Business workflows triggered by events
can be used with Cloud Run to take care of special processing needs like
processing files or ordering inventory. You can also handle events from
other Google Cloud Services and schedule short background tasks. Just to be sure to keep those background
tasks less than 30 minutes in duration. So far, I've only listed when
you should use Google Cloud Run. But when should you look for
alternatives, off the shelf applications? While Cloud Run runs
containerized applications, runtime still has a few limitations. For example, if a container is not
handling requests, it might disappear. Off the shelf applications often
do not expect this to happen and might not handle it well. There're others may just run fine. Cloud Run is not very well suited for long
jobs that last over an hour to complete. If you want to handle this on Cloud Run, try to split the job up into many smaller
tasks that can be handled in parallel. If that's not possible,
start a Compute Engine VM or schedule a job on a Kubernetes cluster. For massive stream and batch data
processing with complex workflows, you're probably better off using
data flow on Google Cloud. It's also serverless and
compatible with Apache Beam. Finally, any workload that requires
a GPU or another type of accelerator, it's not a great idea to train
machine learning models on Cloud Run